
#ifndef _RADIX_DIALECT_MESH_H_
#define _RADIX_DIALECT_MESH_H_

#include <Archaism/Main.h>

_BeginNamespace(Radix)

class Mesh
{
public:
	struct Vertex
	{
		Vector3 position;
		Vector3 normal;
		Color color;
		Vector2 uv;

		Vertex();
		Vertex(const Vector3& position, const Vector3& normal, const Color& color, const Vector2& uv);
	};

	struct Triangle
	{
		uint v1;
		uint v2;
		uint v3;

		Triangle();
		Triangle(uint v1, uint v2, uint v3);
	};

public:
	typedef std::vector<Vertex> VertexVector;
	typedef std::vector<Triangle> TriangleVector;

public:
	Mesh();
	virtual ~Mesh();

public:
	const Vertex* vdata() const;
	uint vcount() const;
	const Triangle* tdata() const;
	uint tcount() const;
	Vertex& vertex(uint i);
	Triangle& triangle(uint i);
	void appendVertex(const Vertex& vertex);
	void appendTriangle(const Triangle& triangle);
	void setVertices(Vertex* vertices, uint count);
	void setTriangles(Triangle* triangles, uint count);
	
public:
	void loadFromFile(const String& fileName);
	void saveToFile(const String& fileName);
	
private:
	VertexVector mVertices;
	TriangleVector mTriangles;
};

_EndNamespace(Radix)

#endif//_RADIX_DIALECT_MESH_H_
